import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15

Window {
    id: root
    width: 430
    height: 332
    visible: true

    //qsTr指翻译
    title: qsTr("作·家")

    //去边框
    flags: Qt.FramelessWindowHint | Qt.Window

    //使鼠标可以任意拖动窗口
    MouseArea {
            anchors.fill: parent
            acceptedButtons: Qt.LeftButton
            property point clickPos: "0,0"
            onPressed: {//鼠标按下保存鼠标位置
                clickPos  = Qt.point(mouseX,mouseY)
            }
            onPositionChanged: {//鼠标位置改变的时候移动窗口
                var delta = Qt.point(mouseX-clickPos.x, mouseY-clickPos.y)
                root.setX(root.x+delta.x)
                root.setY(root.y+delta.y)
            }
    }

    //背景图片
    Image {
        id: bgImage
        source: "/zuojia/Launcher/Images/WinBG1.png"
        anchors.fill: parent
    }

    //关闭按钮
    ControlButton {
        id: closeWin
        width: 22
        height: 22
        anchors.right: parent.right
        anchors.top: parent.top

        havColor: true
        havOpacity: false

        Image {
            width: 18
            height: 18
            source: "/zuojia/Launcher/Images/CloseWin.png"
            anchors.centerIn: parent
        }

        MouseArea {
            anchors.fill: parent
            onClicked: {
              closeApp()
            }
        }

    }

    //最小化按钮
    ControlButton {
        id: minWin
        width: 22
        height: 22
        anchors.right: closeWin.left
        anchors.top: parent.top
        Image {
            width: 17
            height: 3
            source: "/zuojia/Launcher/Images/MinWin.png"
            anchors.centerIn: parent
        }

        MouseArea {
            anchors.fill: parent
            onClicked: {
              minApp()
            }
        }
    }

    //更新按钮
    UiButton {
        objectName: "UpdateBtn"
        id: updateBtn
        anchors.bottom: proBar.top
        anchors.bottomMargin: 24
        anchors.left: parent.left
        anchors.leftMargin: 70
        width: 102
        height: 34
        text: "更新"
        font.family: "/zuojia/Launcher/Fonts/msyh.ttf"
        font.pixelSize: 12
    }

    //启动按钮
    UiButton {
        objectName: "StartBtn"
        id: startBtn
        anchors.bottom: proBar.top
        anchors.bottomMargin: 24
        anchors.left: updateBtn.right
        anchors.leftMargin: 86
        width: 102
        height: 34
        text: "启动"
        font.family: "/zuojia/Launcher/Fonts/msyh.ttf"
        font.pixelSize: 12
    }

    //进度条
    ProBar {
        objectName: "ProBar"
        id: proBar
        value: 0.5
        height: 5
        anchors.bottom: infoTextBG.top
        anchors.left: parent.left
        anchors.right: parent.right

        function setText(proBarValue){
            proBar.value=proBarValue
        }

        function getText(){
            return proBar.value
        }
    }

    //底部提示文本
    Rectangle {
        objectName: "InfoText"
        id: infoTextBG
        anchors.right: parent.right
        anchors.left: parent.left
        anchors.bottom: parent.bottom
        height: 27
        width: root.width
        color: "#444444"

        Label {
            id: infoLabel
            text: qsTr("测试文本")
            anchors.fill: infoTextBG
            verticalAlignment: "AlignVCenter"
            color: "#DDDDDD"
            anchors.leftMargin: 7
            font.family: "/zuojia/Launcher/Fonts/msyh.ttf"
            font.pixelSize: 12
        }

        function setText(infoText){
            infoLabel.text=infoText
        }

        function getText(){
            return infoLabel.text
        }
    }



    function closeApp(){
        root.close()
    }
    function minApp(){
        root.showMinimized()
    }
}
